﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SharingCenter.Web.Classes;
using SharingCenter.Web.Classes.Groups;
using System.Collections;

namespace SharingCenter.Web.Mod.Groups
{
    public partial class Default : GroupsPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GetGroups();
            GetGroupThreads();
            GetGroupEvents();
        }

        private void GetGroupEvents()
        {
            using (scDataContext cxt = new scDataContext())
            {
                string q = string.Format("EXEC GetEventsByUserGroups '{0}', {1}", Profile.UserId, 20);
                lvEventList.DataSource = cxt.ExecuteQuery<Sc_Event>(q);
                lvEventList.DataBind();
            }
        }

        private void GetGroups()
        {
            HotGroupList.GroupList = GroupOperations.GetHotGroups(8);
            NewGroupList.GroupList = GroupOperations.GetNewGroups(8);
        }

        private void GetGroupThreads()
        {
            lvThreadsList.DataSource = PostOperations.GetThreadInGroups(Profile.UserId, 30);
            lvThreadsList.DataBind();
        }

        protected void DateFormat(object sender, EventArgs e)
        {
            Label s = (Label)sender;
            s.Text = Utility.FriendlyDateTime(s.Text, TimeDisplayEnum.LiteralHours, false);
        }
             
    }
}
